package com.qf.controller;

import com.qf.pojo.User;
import com.qf.pojo.UserRole;
import com.qf.service.UserRoleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserRoleController {
    @Resource
    UserRoleService userRoleService;
    @RequestMapping("/findAllUserRole")
    public List<UserRole> findAllUserRole(){

        return userRoleService.findAll();
    }
    @RequestMapping("/findByUrid/{urid}")
    public UserRole findByUrid(@PathVariable("urid")Integer urid){
        return userRoleService.findByUrid(urid);
    }
    @RequestMapping(value = "/addUserRole",method = RequestMethod.POST)
    public int addUserRole(@RequestBody UserRole userRole){
        int add = userRoleService.add(userRole);
        if (add>0){
            return 1;
        }else {
            return 0;
        }
    }
    @RequestMapping(value = "/updateUserRole",method = RequestMethod.POST)
    public int updateUserRole(@RequestBody UserRole userRole){
        int update = userRoleService.update(userRole);
        if (update>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/deleteUserRole/{urid}")
    public int deleteUserRole(@PathVariable("urid")int urid) {
        int delete = userRoleService.delete(urid);
        if (delete>0){
            return 1;
        }else {
            return 0;
        }
    }
}
